__author__ = 'st316'
'''
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai).
n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0).
Find two lines, which together with x-axis forms a container, such that the container contains the most water.

Note: You may not slant the container.
抽象：给出一组数，在这一组数种找出两个数字，使得这两个数的差的绝对值与这两个数种较小的一个数的乘积最大
当宽变短时，只有长变长才能使面积变大
'''


class Solution:
    # @return an integer
    def maxArea(self, height):
        low = 0
        high = len(height) - 1
        maxArea = 0
        while low < high:
            maxArea = max(maxArea, (high - low) * min(height[low], height[high]))
            if height[low] < height[high]:
                low += 1
            else:
                high -= 1
        return maxArea

if __name__ == '__main__':
    s = Solution()
    print s.maxArea([1,2,3,4,5])